#include <pthread.h>
#include <iostream>

#ifndef THREADMANAGER_H_
# define THREADMANAGER_H_

class ThreadManager {
    ThreadManager() {
	if (mutex == 0)
	    mutex = PTHREAD_MUTEX_INITIALIZER;
	if (pthread_mutex_trylock(mutex) != 0) {
	    std::cerr << "there is may be an error while locking thread" << std::endl;
	}
    }
    virtual ~ThreadManager() {
	if (pthread_mutex_unlock(mutex) != 0) {
	    std::cerr << "there is may be an error while unlocking thread" << std::endl;
	}
    }
    static pthread_mutex_t *mutex;
};

#endif /* !THREADMANAGER_H_ */
